//
//  MCAlert.h
//  iMooc
//
//  Created by CoderXSLee on 13/5/3.
//  Copyright © 2013年 李雪松. All rights reserved.
//

#import <UIKit/UIKit.h>

#define DEFAULT_LINE_SPACING        (int)0
#define DEFAULT_PARAGRAPH_SPACING   (int)3

typedef NS_ENUM(NSInteger, MCAlertStyle) {
    MCAlertStyleDefault = 0,
    MCAlertStyleSecureTextInput,
    MCAlertStylePlainTextInput,
    MCAlertStyleLoginAndPasswordInput
};
@class MCAlert;
@protocol MCAlertDelegate;

@interface MCAlert : UIView {
    UITextView *_messageLabel;
    UILabel *_titleLabel;
}
@property (nonatomic, retain) id object;
// delegate
@property (nonatomic, assign, readonly) id<MCAlertDelegate>delegate;

// MCAlertView
@property (nonatomic, strong, readonly) UIView *alertView;

// 内容文字大小
@property (nonatomic, strong) UIFont *font;

// 设置message的对齐方式
@property (nonatomic, assign) NSTextAlignment contentAlignment;

// MCAlert TextInput LoginInput
@property (nonatomic, strong) UITextField *textField;

// MCAlert PasswordInput
@property (nonatomic, strong) UITextField *passwordTextField;

@property (nonatomic, assign) CGFloat lineSpacing;        // DEFAULT_LINE_SPACING
@property (nonatomic, assign) CGFloat paragraphSpacing;   // DEFAULT_PARAGRAPH_SPACING
@property (nonatomic, assign) MCAlertStyle alertStyle;   // DEFAULT_PARAGRAPH_SPACING

// 确认按钮的渐变色数组 [CGColor]
@property(nonatomic, strong) NSArray *cgColors;
// 渐变的位置
@property(nonatomic, strong) NSArray *locations;

#pragma mark - --block
typedef void (^CancelBlock)(MCAlert *alertView) ;
typedef void (^ClicksBlock)(MCAlert *alertView, NSInteger buttonIndex);
@property (nonatomic, copy, readonly) CancelBlock cancelBlock;
@property (nonatomic, copy, readonly) ClicksBlock clickBlock;
- (void)setCancelBlock:(CancelBlock)cancelBlock;
- (void)setClickBlock:(ClicksBlock)clickBlock;

#pragma mark - --init

/**
 *  创建alertView
 *
 *  @param title             提示标题
 *  @param message           提示详情
 *  @param delegate          协议对象
 *  @param cancelButtonTitle 取消按钮名称
 *  @param otherButtonTitles 其他按钮
 *
 *  @return MCAlert *
 */
- (instancetype)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id<MCAlertDelegate>)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;

/**
 *  显示alertView
 */
- (void)show;
@end

#pragma mark - --delegate
@protocol MCAlertDelegate <NSObject>

@optional
/**
 *  点击按钮协议
 *
 *  @param alertView MCAlert *
 *  @param buttonIndex 0,1,2...
 */
- (void)alertView:(MCAlert *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;

/**
 *  取消协议
 *
 *  @param alertView MCAlert *
 */
- (void)alertViewCancel:(MCAlert *)alertView;

@end
